https://www.jianshu.com/p/cc0ac7845ded
<!--HTML-->
<ul>
    <li>
        <a href="#content1">选项一</a>
        <div class="content" id="content1">选项一内容</div>
        
    </li>
    <li>
        <div class="content" id="content2">选项二内容</div>
        <a href="#content2">选项二</a>
    </li>
    <li>
        <div class="content" id="content3">选项三内容</div>
        <a href="#content3">选项三</a>
    </li>
</ul>
<style>
    /*CSS*/
    * {
        margin: 0;
        padding: 0;
    }

    a {
        text-decoration: none;
        color: #000;
    }

    ul {
        position: relative;
        width: 300px;
        margin: 100px auto;
    }

    ul li {
        list-style: none;
    }

    ul li a {
        float: left;
        width: 100px;
        text-align: center;
        line-height: 30px;
        border: 1px solid #000;
        border-right: 0;
        box-sizing: border-box;
        cursor: pointer;
        transition: all .3s;
    }

    ul li:last-child a {
        border-right: 1px solid #000;
    }

    ul li .content {
        opacity: 0;
        position: absolute;
        left: 0;
        top: 31px;
        width: 100%;
        height: 300px;
        border: 1px solid #000;
        box-sizing: border-box;
        font-size: 24px;
        text-align: center;
        line-height: 300px;
        color: #fff;
        transition: all .3s;
    }

    ul li:nth-child(1) .content {
        background-color: #0f0;
        opacity: 1; /* 添加默认状态 */
    }

    ul li:nth-child(2) .content {
        background-color: #00f;
    }

    ul li:nth-child(3) .content {
        background-color: #f0f;
    }

    ul li .content:target {
        opacity: 1;
    }

    ul li .content:target+a {
        color: #fff;
        background-color: #000;
    }
</style>